<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/24/024
 * Time: 17:41
 */

namespace app\lib\exception;


use app\lib\DingDing\DingDingNotice;
use Exception;
use think\exception\Handle;
use think\Request;

class ExceptionHandle extends Handle
{
    public function render(Exception $e)
    {
        if($e instanceof BaseException){
            switch ($e->errorCode){
                case 10000:
                    $webhook = "https://oapi.dingtalk.com/robot/Send?access_token=2bc87d1b37a25b790e02534ad6bca312cbba2dd0e1a6aa0299ab32b37ec5250b";
                    $message="你们好！";
                    (new DingDingNotice())->setWebHook($webhook)->setContent($message)->setAtMobiles(18680151308)->save();
                    break;
            }
        }
//        if($e->code == 500){
//           $request =  Request::instance();
//            $request->url('/admin/index/index');
//        }
        return parent::render($e); // TODO: Change the autogenerated stub

    }
}